package com.blb.demo3;

import java.time.LocalDateTime;
import java.util.concurrent.*;

/**
 * 线程池案例
 * 自己设置参数的线程池
 */
public class ExecutorDemo5 {

    public static void testNewCachedThreadPool() {
        int cpuNum = Runtime.getRuntime().availableProcessors();
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(cpuNum * 2, cpuNum * 2,
                0, TimeUnit.SECONDS, new LinkedBlockingDeque<>());
        threadPoolExecutor.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName() + "执行了");
            }
        });
        threadPoolExecutor.shutdown();
    }

    public static void main(String[] args) {
        testNewCachedThreadPool();
    }

}
